{include file=header.html}

<script type="text/javascript" language="javascript" src="{lib file=jquery-1.6.3.min.js}"></script>
<script language="javascript" type="text/javascript" src="{lib file=jquery.ui/jquery.ui.js}"></script>

<script language="javascript" type="text/javascript" src="{lib file=jquery.ui/chosen.jquery.js}"></script>

<link type="text/css" rel="stylesheet"  href="{lib file=jquery.ui/themes/chosen/chosen.css}">

<script language="javascript" type="text/javascript" src="{res file=js/jquery.funkyUI.js}"></script>

<script language="javascript" type="text/javascript" src="{lib file=jquery.plugins/jquery.validate.js}"></script>

<script language="javascript" type="text/javascript" src="{res file=js/common.js}"></script>
  <script>
$(function() {
   // $("#recipient").chosen();
	
//	$("#cate_id").change(function(){
//		if($(this).val()==3||$(this).val()==4)
//		{
//			$("#tr_recipient").show();
//		}
//		else
//		{
//			$("#tr_recipient").hide();
//		}
//		
//		});
		
	   $('#newsform').validate({
        onkeyup : false,
		onfocusout : false,
		rules : {
			title: {
				required: true
			},
			cate_id: {
				range: [1,4]
			}
		},
		messages : {
			title: {
				required: '{$lang.title_required}'
			},
			cate_id: {
				range: '{$lang.cate_id_required}'
			}
		}
	 });
});
  
  function addfac(op,objthis)
  {
	  if(op=="gc")
	  {
	  if(objthis.checked)
	  {
		 $("#recipient optgroup[label='工厂'] option").attr("selected","selected");
	  }
	  else
	  {
		 $("#recipient optgroup[label='工厂'] option").removeAttr("selected");
	  }

	  $("#recipient").trigger("liszt:updated");

	  }
	  else if(op=="yg")
	  {
	  if(objthis.checked)
	  {
		 $("#recipient optgroup[label='员工'] option").attr("selected","selected");
	  }
	  else
	  {
		 $("#recipient optgroup[label='员工'] option").removeAttr("selected");
	  }
	  $("#recipient").trigger("liszt:updated");
	  		  
	  }
  }
  
  </script>
<style type="text/css">
input {
	vertical-align: -5px;_vertical-align: -1px;margin-right: 5px
}
</style>
<body>
<div class="sub-body">
<div class="tab-frame" style="width:800px;">
<div class="tab-title-1">
<!--{if $smarty.get.act eq 'add'}--><span>{$lang.add_news}</span><!--{else}--><span>{$lang.edit_news}</span><!--{/if}-->
</div>
{$build_editor}

<form id="newsform" action="{url app=news&act=$smarty.get.act}{if $smarty.get.news_id}&amp;news_id={$smarty.get.news_id}{/if}" method="post">
<table width="100%" cellspacing="0" cellpadding="0" class="tab-display">
	<tr>
		<th width="25%" align="right">{$lang.title}：</th>
		<td align="left"><input type="text" name="title" value="{$news.title}" style="width:100%;" class="input-3" /></td>
	</tr>
	<tr>
		<th align="right">{$lang.category}：</th>
		<td align="left">
			{foreach from=$lang.news_cate item=cate key=cate_id}
				<input name="cate_id[]" value="{$cate_id}" {if $smarty.get.act eq edit} <!-- {if in_array($cate_id,$news.c_arr_id)} -->checked<!-- {/if} -->{/if} type="checkbox">{$cate}&nbsp;
			{/foreach}
		</td>
		<!-- <td align="left">
			<select name="cate_id" id="cate_id" style="width:150px;">
				<option value="0">{$lang.select_pls}</option>
				{foreach from=$lang.news_cate item=cate key=cate_id}
				<option value="{$cate_id}" {if $cate_id == $news.cate_id}selected{/if}>{$cate}</option>
				{/foreach}
			</select>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;

		</td> -->
	</tr>
    <!-- <tr id="tr_recipient" {if $smarty.get.act eq 'add' or $news.cate_id eq NEWS_CATE_GC or $news.cate_id eq NEWS_CATE_YG }style="display:none;"{/if}> 
		<th align="right">{$lang.recipient}：</th>
		<td align="left" style="display:none;">
            <select title="按CTRL键可多选" disabled data-placeholder="请选择接收人" style="width: 350px; " class="chzn-select" {if $smarty.get.act eq 'add'}multiple=""{/if} tabindex="-1" id="recipient" name="{if $smarty.get.act eq 'add'}recipient[]{else}recipient{/if}">
                <option value=""></option>
                <optgroup label="工厂" >
                {foreach from=$user_gc item=user1}
                  <option value="{$user1.user_id}" {if $news.to_id eq $user1.user_id}selected{/if}>{$user1.user_name}</option>
                 {/foreach}
                </optgroup>
                <optgroup label="员工">
                {foreach from=$user_yg item=user2}
                  <option value="{$user2.user_id}" {if $news.to_id eq $user2.user_id}selected{/if}>{$user2.user_name}</option>
                 {/foreach}
                </optgroup>
              </select>
              {if $smarty.get.act eq 'add'}
              <label><input type="checkbox" id="test" onChange="addfac('gc',this);" />所有工厂</label>
              <label><input type="checkbox" onChange="addfac('yg',this);" />所有员工</label>
              {/if}
		</td>
	</tr> -->
	<tr>
		<th align="right">{$lang.content}：</th>
		<td align="left">
			<textarea name="content" style="width:700px; height:400px;">{$news.content}</textarea>
			<input type="button" class="btn-2" value="上传图片" style="margin:5px 0 0 0;" onClick="upload_news_pic({if $news.news_id}{$news.news_id}{else}{$default_new_id}{/if});"><br>
			<style type="text/css">
			<!--
			.news_imgs {float:left; width:600px; margin:3px;}
			.news_imgs li {float:left; width:50px; margin:0 2px 0 2px; padding:2px;border:1px solid #F4F8FA;}
			.news_imgs li.border {border:1px solid #FF9933;}
			.news_imgs li p {margin:0; padding:0; float:left; text-align:center; width:50px;}
			.news_imgs li p img {width:50px; cursor:pointer;}
			.news_imgs li p a {margin:4px 5px 0 0; float:right;}
			.news_imgs li p a.undis {display:none;}
			-->
			</style>
			<script>
			function insertImage(obj) {
				tinyMCE.execCommand('mceInsertContent', false, '<img src="' + obj.attr('src') + '" />');
			}
			function uploadImage() {
			}
			function dropImage(obj, id) {
				$.ajax({
					url: 'index.php?app=comupload&act=delete&id=' + id + '&ajax=1',
					type: 'GET',
					timeout: 1000,
					error: function () {alert('网络连接错误，请稍后再试');},
					success: function (data) {
						if (data) {
							obj.parent().parent().remove();
						}
					}
				});
			}
			</script>
			<ul class="news_imgs" id="news_images">
				<!--{foreach from=$images item=image}-->
				<li onMouseOver="this.className='border';this.getElementsByTagName('a')[0].className='pic_del';" onMouseOut="this.className='';this.getElementsByTagName('a')[0].className='pic_del undis';">
					<p><img src="{$image.file_path}" title="点击插入图片" onClick="insertImage($(this))" /><input type="hidden" name="images[]" value="{$image.file_id}"></p>
					<p style="height:20px;"><a href="" title="点击删除图片" onClick="if(confirm('{$lang.confirm_del_image}')){dropImage($(this), {$image.file_id});} return false;" class="pic_del undis">删除</a></p>
				</li>
				<!--{/foreach}-->
			</ul>
		</td>
	</tr>
	<tr>
		<th align="right">{$lang.if_show}：</th>
		<td align="left"><label><input type="radio" name="if_show" {if $news.if_show}checked{/if} value="1" />{$lang.yes}</label>&nbsp;&nbsp;<label><input type="radio" name="if_show" {if !$news.if_show}checked{/if} value="0" />{$lang.no}</label></td>
	</tr>
	<!--{if $smarty.get.act eq 'edit'}-->
	<tr>
		<th align="right">附件：</th>
		<td class="tab-align-l">
			<span id="news_files" style="float:left;">
			<!--{foreach from=$files item=file name=f}-->
			<a href="download.php?id={$file.file_id}">{$file.file_name}</a><a class="pic_del" href="{url app=comupload&act=delete&id=$file.file_id}" onClick="return confirm('{$lang.confirm_del_file}')" title="{$lang.delete}">&nbsp;</a><!--{if !$smarty.foreach.f.last}--><br /><!--{/if}-->
			<!--{/foreach}-->
			</span>
			<span style="float:left; margin-left:30px;"><input type="button" class="btn-3" value="{$lang.upload_enclosure}" onClick="upload_docs({$belongs_newsfile}, {$news.news_id});" /></span></td>
	</tr>
	<!--{/if}-->
	<tr>
		<td colspan="2" align="center"><input type="submit" value="{$lang.submit}" class="btn-2"/></td>
	</tr>
</table>
</form>
<script language="javascript" type="text/javascript" src="{res file=js/tab_color.js}"></script>
</div>
</div>
</body>
</html>